<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"> <style>
	.KEYW {color: #933;}
	.COMM {color: #bbb; font-style: italic;}
	.NUMB {color: #393;}
	.STRN {color: #393;}
	.REGX {color: #339;}
	.line {border-right: 1px dotted #666; color: #666; font-style: normal;}
	</style></head><body><pre><span class='line'>  1</span> <span class="COMM">/*
<span class='line'>  2</span>  * $Id: om-messagetip.js,v 1.11 2012/06/21 03:09:30 wangfan Exp $
<span class='line'>  3</span>  * operamasks-ui omMessageBox @VERSION
<span class='line'>  4</span>  *
<span class='line'>  5</span>  * Copyright 2011, AUTHORS.txt (http://ui.operamasks.org/about)
<span class='line'>  6</span>  * Dual licensed under the MIT or LGPL Version 2 licenses.
<span class='line'>  7</span>  * http://ui.operamasks.org/license
<span class='line'>  8</span>  *
<span class='line'>  9</span>  * http://ui.operamasks.org/docs/
<span class='line'> 10</span>  *
<span class='line'> 11</span>  * Depends:
<span class='line'> 12</span>  *  om-core.js
<span class='line'> 13</span>  */</span><span class="WHIT">
<span class='line'> 14</span> </span><span class="WHIT"> </span><span class="WHIT">
<span class='line'> 15</span> </span><span class="PUNC">(</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="WHIT"> </span><span class="NAME">$</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="WHIT"> </span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 16</span> </span><span class="WHIT">     </span><span class="COMM">/**
<span class='line'> 17</span>       * @name omMessageTip
<span class='line'> 18</span>       * @class
<span class='line'> 19</span>       * omMessageTip用于右下角弹出提示窗口（像QQ新闻一样）。&lt;br/>&lt;br/>
<span class='line'> 20</span>       * &lt;br/>
<span class='line'> 21</span>       * &lt;h2>有以下特点：&lt;/h2>&lt;br/>
<span class='line'> 22</span>       * &lt;ul>
<span class='line'> 23</span>       *     &lt;li>不中断用户操作（非模态窗口提示）&lt;/li>
<span class='line'> 24</span>       *     &lt;li>有较好的浏览器兼容性&lt;/li>
<span class='line'> 25</span>       *     &lt;li>可以定义标题、内容，并且标题和内容可以使用html代码&lt;/li>
<span class='line'> 26</span>       *     &lt;li>支持丰富的提示（图标不同）&lt;/li>
<span class='line'> 27</span>       *     &lt;li>可以监听关闭事件&lt;/li>
<span class='line'> 28</span>       *     &lt;li>弹出提示和关闭提示时有简单动画&lt;/li>
<span class='line'> 29</span>       *     &lt;li>较轻量（仅简单的提示功能和定时消失功能，不可改变提示窗口大小，不可拖动提示窗口位置）&lt;/li>
<span class='line'> 30</span>       * &lt;/ul>
<span class='line'> 31</span>       * &lt;br/>
<span class='line'> 32</span>       * 该组件非常轻量，功能也较少，如果需要中断用户操作，请使用omDialog或omMessageBox组件。内容区也仅能放html代码，如果有较复杂的内容请使用omDialog组件。
<span class='line'> 33</span>       * &lt;br/>
<span class='line'> 34</span>       * &lt;h2>提供了以下工具方法：&lt;/h2>&lt;br/>
<span class='line'> 35</span>       * &lt;ul>
<span class='line'> 36</span>       *     &lt;li>
<span class='line'> 37</span>       *         &lt;b>$.omMessageTip.show(config)&lt;/b>&lt;br/>
<span class='line'> 38</span>       *         从当前页面右下角弹出一个非中断提示，弹出的提示可以关闭。其中config有以下配置项：&lt;br/>
<span class='line'> 39</span>       *         &lt;ul style="margin-left:40px">
<span class='line'> 40</span>       *             &lt;li>type：提示的类型，类型不同时弹出窗口左边的图标会不同。String类型，可选的值有'alert'、'success'、'error'、'question'、'warning'、'waiting'。默认值为'alert'。&lt;/li>
<span class='line'> 41</span>       *             &lt;li>title：弹出窗口的标题文字，String类型，可以使用普通字符串，也可以使用html代码。默认值为'提示'。&lt;/li>
<span class='line'> 42</span>       *             &lt;li>content：弹出窗口的提示内容，String类型，可以使用普通字符串，也可以使用html代码。无默认值。&lt;/li>
<span class='line'> 43</span>       *             &lt;li>onClose：弹出窗口关闭时的无参回调函数，Function类型。&lt;/li>
<span class='line'> 44</span>       *             &lt;li>timeout：弹出窗口持续的时间，单位为毫秒，窗口弹出后经过这么长的时间后自动关闭（如果有onClose回调函数，会自动触发它），Int类型。默认值为无穷大（即不自动关闭）&lt;/li>
<span class='line'> 45</span>       *         &lt;/ul>
<span class='line'> 46</span>       *         &lt;br/>使用方式如下：&lt;br/>
<span class='line'> 47</span>       *         &lt;pre>
<span class='line'> 48</span>       *             $.omMessageTip.show({
<span class='line'> 49</span>       *                 type:'warning',
<span class='line'> 50</span>       *                 title:'提醒',
<span class='line'> 51</span>       *                 content:'请选择你要删除的记录（可以选择一条或多条）！'
<span class='line'> 52</span>       *             });
<span class='line'> 53</span>       *             $.omMessageTip.show({
<span class='line'> 54</span>       *                 type:'error',
<span class='line'> 55</span>       *                 title:'数据非法',
<span class='line'> 56</span>       *                 content:'&lt;font color="red">123456&lt;/font>不是有效的邮箱地址！',
<span class='line'> 57</span>       *                 onClose:function(){
<span class='line'> 58</span>       *                     $('#emial').focus();
<span class='line'> 59</span>       *                 }
<span class='line'> 60</span>       *             });
<span class='line'> 61</span>       *         &lt;/pre>
<span class='line'> 62</span>       *     &lt;/li>
<span class='line'> 63</span>       * &lt;/ul>
<span class='line'> 64</span>       */</span><span class="WHIT">
<span class='line'> 65</span> </span><span class="WHIT">    </span><span class="NAME">$.omMessageTip</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 66</span> </span><span class="WHIT">        </span><span class="NAME">show</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">config</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 67</span> </span><span class="WHIT">            </span><span class="NAME">config</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">$.extend</span><span class="PUNC">(</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 68</span> </span><span class="WHIT">                </span><span class="NAME">title</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'提醒'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 69</span> </span><span class="WHIT">                </span><span class="NAME">content</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'&#160;'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 70</span> </span><span class="WHIT">                </span><span class="NAME">type</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'alert'</span><span class="WHIT">
<span class='line'> 71</span> </span><span class="WHIT">            </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="NAME">config</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 72</span> </span><span class="WHIT">            </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">html</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'&lt;div class="om-messageTip om-widget om-corner-all" tabindex="-1">'</span><span class="PUNC">+</span><span class="WHIT">
<span class='line'> 73</span> </span><span class="WHIT">                    </span><span class="STRN">'&lt;div class="om-widget-header om-corner-top om-helper-clearfix">'</span><span class="PUNC">+</span><span class="WHIT">
<span class='line'> 74</span> </span><span class="WHIT">                        </span><span class="STRN">'&lt;span class="om-messageTip-title">'</span><span class="PUNC">+</span><span class="NAME">config.title</span><span class="PUNC">+</span><span class="STRN">'&lt;/span>'</span><span class="PUNC">+</span><span class="WHIT">
<span class='line'> 75</span> </span><span class="WHIT">                        </span><span class="STRN">'&lt;a href="#" class="om-messageTip-titlebar-close om-corner-tr">&lt;span class="om-icon-closethick">&lt;/span>&lt;/a>'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT">
<span class='line'> 76</span> </span><span class="WHIT">                    </span><span class="STRN">'&lt;/div>'</span><span class="PUNC">+</span><span class="WHIT">
<span class='line'> 77</span> </span><span class="WHIT">                    </span><span class="STRN">'&lt;div class="om-messageTip-content om-widget-content om-corner-bottom">'</span><span class="PUNC">+</span><span class="WHIT">
<span class='line'> 78</span> </span><span class="WHIT">                        </span><span class="STRN">'&lt;div class="om-messageTip-image om-messageTip-image-'</span><span class="PUNC">+</span><span class="NAME">config.type</span><span class="PUNC">+</span><span class="STRN">'">&lt;/div>'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT">
<span class='line'> 79</span> </span><span class="WHIT">                        </span><span class="STRN">'&lt;div class="om-messageTip-content-body">'</span><span class="PUNC">+</span><span class="NAME">config.content</span><span class="PUNC">+</span><span class="STRN">'&lt;/div>'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT">
<span class='line'> 80</span> </span><span class="WHIT">                    </span><span class="STRN">'&lt;/div>'</span><span class="PUNC">+</span><span class="WHIT">
<span class='line'> 81</span> </span><span class="WHIT">                </span><span class="STRN">'&lt;/div>'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 82</span> </span><span class="WHIT">            </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">messageTip</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">$</span><span class="PUNC">(</span><span class="NAME">html</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">appendTo</span><span class="PUNC">(</span><span class="NAME">document.body</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">css</span><span class="PUNC">(</span><span class="STRN">'z-index'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">3000</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">hide</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 83</span> </span><span class="WHIT">            </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">result</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="NAME">d</span><span class="PUNC">:</span><span class="NAME">messageTip</span><span class="PUNC">,</span><span class="NAME">l</span><span class="PUNC">:</span><span class="NAME">config.onClose</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 84</span> </span><span class="WHIT">            </span><span class="NAME">messageTip.find</span><span class="PUNC">(</span><span class="STRN">'a.om-messageTip-titlebar-close'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 85</span> </span><span class="WHIT">                </span><span class="PUNC">.</span><span class="NAME">bind</span><span class="PUNC">(</span><span class="STRN">'mouseenter mouseleave'</span><span class="PUNC">,</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 86</span> </span><span class="WHIT">                    </span><span class="NAME">$</span><span class="PUNC">(</span><span class="KEYW">this</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">toggleClass</span><span class="PUNC">(</span><span class="STRN">'om-state-hover'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 87</span> </span><span class="WHIT">                </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 88</span> </span><span class="WHIT">                </span><span class="PUNC">.</span><span class="NAME">bind</span><span class="PUNC">(</span><span class="STRN">'focus blur'</span><span class="PUNC">,</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 89</span> </span><span class="WHIT">                    </span><span class="NAME">$</span><span class="PUNC">(</span><span class="KEYW">this</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">toggleClass</span><span class="PUNC">(</span><span class="STRN">'om-state-focus'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 90</span> </span><span class="WHIT">                </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 91</span> </span><span class="WHIT">                </span><span class="PUNC">.</span><span class="NAME">bind</span><span class="PUNC">(</span><span class="STRN">'mousedown mouseup'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 92</span> </span><span class="WHIT">                    </span><span class="NAME">$</span><span class="PUNC">(</span><span class="KEYW">this</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">toggleClass</span><span class="PUNC">(</span><span class="STRN">'om-state-mousedown'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 93</span> </span><span class="WHIT">                </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 94</span> </span><span class="WHIT">                </span><span class="PUNC">.</span><span class="NAME">click</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">event</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 95</span> </span><span class="WHIT">                    </span><span class="NAME">$.omMessageTip._close</span><span class="PUNC">(</span><span class="NAME">result</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 96</span> </span><span class="WHIT">                    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 97</span> </span><span class="WHIT">                </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 98</span> </span><span class="WHIT">            </span><span class="NAME">messageTip.slideDown</span><span class="PUNC">(</span><span class="STRN">'slow'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 99</span> </span><span class="WHIT">            </span><span class="WHIT">
<span class='line'>100</span> </span><span class="WHIT">            </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">timer</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>101</span> </span><span class="WHIT">            </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">timeout</span><span class="PUNC">(</span><span class="NAME">time</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>102</span> </span><span class="WHIT">            	</span><span class="NAME">timer</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">setTimeout</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>103</span> </span><span class="WHIT">                    </span><span class="NAME">$.omMessageTip._close</span><span class="PUNC">(</span><span class="NAME">result</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>104</span> </span><span class="WHIT">                </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="NAME">time</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>105</span> </span><span class="WHIT">            </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>106</span> </span><span class="WHIT">            </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">config.timeout</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT"> </span><span class="COMM">//定时关闭</span><span class="WHIT">
<span class='line'>107</span> </span><span class="WHIT">              </span><span class="NAME">timeout</span><span class="PUNC">(</span><span class="NAME">config.timeout</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>108</span> </span><span class="WHIT">            </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>109</span> </span><span class="WHIT">            </span><span class="WHIT">
<span class='line'>110</span> </span><span class="WHIT">            </span><span class="NAME">messageTip.bind</span><span class="PUNC">(</span><span class="STRN">'mouseover'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>111</span> </span><span class="WHIT">            		</span><span class="NAME">clearTimeout</span><span class="PUNC">(</span><span class="NAME">timer</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>112</span> </span><span class="WHIT">            </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">bind</span><span class="PUNC">(</span><span class="STRN">'mouseout'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>113</span> </span><span class="WHIT">            	</span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">timer</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>114</span> </span><span class="WHIT">            		</span><span class="NAME">timeout</span><span class="PUNC">(</span><span class="NAME">config.timeout</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>115</span> </span><span class="WHIT">            	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>116</span> </span><span class="WHIT">            </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>117</span> </span><span class="WHIT">            </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">messageTip</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>118</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>119</span> </span><span class="WHIT">        </span><span class="NAME">_close</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">result</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>120</span> </span><span class="WHIT">            </span><span class="NAME">result.d.slideUp</span><span class="PUNC">(</span><span class="STRN">'slow'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>121</span> </span><span class="WHIT">            </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">result.l</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>122</span> </span><span class="WHIT">                </span><span class="NAME">result.l</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">//调用onClose回调函数</span><span class="WHIT">
<span class='line'>123</span> </span><span class="WHIT">            </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>124</span> </span><span class="WHIT">            </span><span class="NAME">setTimeout</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>125</span> </span><span class="WHIT">                </span><span class="NAME">result.d.remove</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>126</span> </span><span class="WHIT">            </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="NUMB">1000</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>127</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>128</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>129</span> </span><span class="PUNC">}</span><span class="PUNC">(</span><span class="NAME">jQuery</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span></pre></body></html>